//
//  XLPlayerParseHandler.h
//  FFMpegKitDemo
//
//  Created by ilongge on 2023/8/3.
//

#import <Foundation/Foundation.h>
#import <libavformat/avformat.h>

@class XLPlayerConfig; 

@interface XLPlayerParseHandler : NSObject
#pragma mark ------------------------- 初始化 / Initializer
/**
 * 类方法
 * Class Method
 * 初始化解析器，若初始化失败，可读取error字段值。
 * Initialize the parseHandler. If initialization failed, read error.
 * @param  URL 资源链接 / Resource URL
 * @param  error 错误 / Error
 * @return 解码器实例 / XLPlayerParseHandler Instance
 */
+ (instancetype)parseHandlerWithURL:(NSURL *)URL error:(NSError **)error;
/**
 * 实例方法
 * Instance Method
 * 初始化解析器，若初始化失败，可读取error字段值。
 * Initialize the parseHandler. If initialization failed, read error.
 * @param  URL 资源链接 / Resource URL
 * @param  error 错误 / Error
 * @return 解码器实例 / XLPlayerParseHandler Instance
 */
- (instancetype)initWithURL:(NSURL *)URL error:(NSError **)error;
/**
 * 解器器当前的配置
 * Current configuration of the decoder
 */
@property (readonly, strong, nonatomic) XLPlayerConfig *config;
/**
 * 解码器当前的资源地址
 * Current resource URL of the decoder
 */
@property (readonly, strong, nonatomic) NSURL *url;
- (void)prepareParseError:(NSError **)error;
- (AVFormatContext *)formatContext;
- (int)videoStreamIndex;
- (int)audioStreamIndex;
- (void)startParse:(void(^)(BOOL isVideo, AVFrame *frame))handler;
- (void)readNext:(BOOL)next;
@end

